package reflect;

/**
 * 类的初始化过程
 */
public class Test02 {
    static {
        System.out.println("Main类初始化");
    }

    public static void main(String[] args) throws ClassNotFoundException {
        // 1.主动引用
        //Son son = new Son();
        // 2.反射引用
        //Class.forName("reflect.Son");
        // 3.不发生初始化
        //System.out.println(Son.a);
        // 4.使用数组
        //Son[] sons = new Son[5];
        // 5.常量
        System.out.println(Son.b);
    }
}
class Father {
    static int a = 2;
    static {
        System.out.println("父类初始化");
    }
}
class Son extends Father {
    static final int b = 5;
    static {
        System.out.println("子类初始化");
    }
}